package com.jxc.jxc01.hch.entity;

import java.util.Objects;

/**
 * 返回的结果
 */
public class RespResult {
    public int code;
    public String message;
    /**
     * 数据总个数---总记录数
     * */
    private int count;
    /**
     * 后端返回的数据
     */
    public Object data;


    public RespResult() {
    }

    public RespResult(int code, String message, int count, Object data) {
        this.code = code;
        this.message = message;
        this.count = count;
        this.data = data;
    }

    /**
     * 成功响应
     */
    public static RespResult success() {
        RespResult result = new RespResult();
        result.setCode(1);
        result.setMessage("success...");
        return result;
    }

    /**
     * 失败响应
     */
    public static RespResult fail() {
        RespResult result = new RespResult();
        result.setCode(0);
        result.setMessage("fail...");
        return result;
    }

    /**
     * 获取
     *
     * @return code
     */
    public int getCode() {
        return code;
    }

    /**
     * 设置
     *
     * @param code
     */
    public void setCode(int code) {
        this.code = code;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
    /**
     * 获取
     *
     * @return message
     */
    public String getMessage() {
        return message;
    }

    /**
     * 设置
     *
     * @param message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * 获取
     *
     * @return data
     */
    public Object getData() {
        return data;
    }

    /**
     * 设置
     *
     * @param data
     */
    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "RespResult{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", count=" + count +
                ", data=" + data +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RespResult result = (RespResult) o;
        return code == result.code && count == result.count && Objects.equals(message, result.message) && Objects.equals(data, result.data);
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, message, count, data);
    }
}
